package com.aaa.rent.controller.api;

import com.aaa.entity.CarType;
import com.aaa.rent.service.CarTypeService;
import com.aaa.security.annotation.HasPermission;
import com.aaa.security.annotation.MyLog;
import com.aaa.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wys
 * @version 1.0
 * @date 2023/3/2 9:56
 */
@Api(value = "rent/api/AipCarTypeController", tags = {"api车辆类型控制"})
@RestController
@RequestMapping("rent/api/AipCarTypeController")
public class AipCarTypeController {
    @Autowired
    private CarTypeService carTypeService;

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "CarType", name = "carType", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("selectCarType")
    @HasPermission(value = "rent:type")
    @MyLog(title = "查询车辆类型")
    public Result selectCaRType(@RequestBody CarType carType,
                                @RequestParam Integer currentPage,
                                @RequestParam Integer pageSize)
    {return carTypeService.selectCarType(carType,currentPage,pageSize);}

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "CarType", name = "carType", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("insertCarType")
    public Result insert(@RequestBody CarType carType){
        return carTypeService.insertCarType(carType);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "id", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("deleteCarType")
    public Result delete(Integer id){
        return carTypeService.deleteCarType(id);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "CarType", name = "carType", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @RequestMapping("updateCarType")
    public Result update(@RequestBody CarType carType){
        return carTypeService.update(carType);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "string", name = "tname", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("selectAllCarType")
    public Result selectAllCaRType(Integer currentPage,Integer pageSize,String tname) {
        return carTypeService.selectAllCarType(currentPage,pageSize,tname);
    }

}
